/*
 * @Author: luoqi
 * @Date: 2022-03-28 12:51:10
 * @LastEditors: luoqi
 * @LastEditTime: 2022-04-04 17:43:35
 * @Description: 
 */
import {ADDTAB,DELTAB,CHANGEACTIVE} from './constent'
let initState={
  panes:[{name:'主页',key:'home'}],//标签列表
  activeKey:'home'//激活项
}

export default function tabReducer(pre=initState,action){
  let {type,data}=action;
  // console.log(data)
  switch(type){
    case ADDTAB:
      pre.panes.push(data)
      break;
    case DELTAB://删除标签
      pre.panes=pre.panes.filter((item)=>item.key!=data.key)
      break;
    case CHANGEACTIVE:
      pre.activeKey=data.activeKey;
      break;
  }
  return JSON.parse(JSON.stringify(pre))
}